package health.lm.com.mine.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.mine.R;
import health.lm.com.mine.entity.CardCenterEntity;

/**
 * 优惠券
 */

public class CardCenterAdapter extends BaseQuickAdapter<CardCenterEntity.Union_list,BaseViewHolder> {
    public CardCenterAdapter(@Nullable List<CardCenterEntity.Union_list> data) {
        super(R.layout.item_card_center, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CardCenterEntity.Union_list item) {
        helper.setText(R.id.tv_name,item.getTitle())
                .setText(R.id.tv_discount,item.getDiscount())
                .setText(R.id.tv_adr,String.format("地址:%s",item.getAddress()));
        helper.setBackgroundRes(R.id.ll_card,bg(helper.getLayoutPosition()));
        ImageLoaderHelper.getInstance().load(mContext,item.getThumb(),helper.getView(R.id.iv_logo));
    }
    private int bg(int pos){
        int i = R.drawable.card_base_01;
        if (pos%3 == 0){
            i = R.drawable.card_base_01;
        }else if(pos%3 == 1){
            i = R.drawable.card_base_02;
        }else if(pos%3 == 2){
            i = R.drawable.card_base_03;
        }
        return i;
    }
}
